Component({
  externalClasses: ['v-oilshow'],
  properties: {

    oilShow: {
      type: Boolean,
      value: false,
      observer: function (newVal, oldVal) {
        console.log(newVal,oldVal,"123123123")
        // 属性值变化时执行
      }
    },
    oilnum:{
      type:Array,
      value:[],
      observer:function(newVal,oldVal){
        console.log(newVal.length)
        if(newVal.length){
          console.log(newVal, oldVal, "油号")
          this.triggerEvent('oilClick', { oilitem: newVal[0].productInfoName, productInfoId: newVal[0].productInfoId, productId: newVal[0].productId}, {})
        }
      }
    },
    posnum: {
      type: Array,
      value: [],
      observer: function (newVal, oldVal) {
        
        if(newVal.length){
          console.log(newVal, "设备")
          this.triggerEvent('oilClick1', { pos: newVal[0].terminalSortName, idx: newVal[0].id }, {})
        }
      }
    },
  },
  data: {
   currentIndex:"",
   currentIndex1:"",
   oilitem:"",
   positem:"",
   productInfoId:""
  },
  methods: {
    //点击选择油品和设备号
    oilClick(event){
      //1.获取index
      const index = event.currentTarget.dataset.index
      const oilitem = event.currentTarget.dataset.item;
      const productInfoId = event.currentTarget.dataset.productinfoid
      const productId = event.currentTarget.dataset.productid
      const idx=event.currentTarget.dataset.idx
      console.log(event,"event")
      //改变记录的currentindex
      this.setData({
        currentIndex:index,
        oilitem:oilitem,
        productInfoId: productInfoId,
        productId:productId
      })
      //发出自定义事件
      console.log("发出自定义事件")
      this.triggerEvent('oilClick', { oilitem, productInfoId,productId},{})
    },
    posItemClick(event){
      //1.获取index
      const index= event.currentTarget.dataset.index
      const pos=event.currentTarget.dataset.pos;
      const idx=event.currentTarget.dataset.idx
      console.log(event, "event")
      //改变记录的currentindex
      this.setData({
        currentIndex1: index,
        positem:pos
      })
      //发出自定义事件
      this.triggerEvent('oilClick1', { pos,idx }, {})
    },
    //点击确定时
    vehicleTap: function (event) {
      let val = event.currentTarget.dataset.value;
      let val1=event.currentTarget.dataset.value1;
      console.log(val,"油品")
      console.log(val1,"设备")
      this.setData({
        oilShow: false
      })
      this.triggerEvent('sure', { val, val1 }, {})
    },
  }
});